package com.itshops.controller;

import com.google.gson.Gson;
import com.itshops.entity.Type;
import com.itshops.service.TypeService;
import com.itshops.service.impl.TypeServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;
@WebServlet("/type")
public class TypeController extends BaseServlet{
    TypeService typeService=new TypeServiceImpl();

    //显示所有商品类别
    public String findAll(HttpServletRequest req, HttpServletResponse resp) throws SQLException {

        //调用业务逻辑
        List<Type> all = typeService.findAll();
        //将集合转换成对应的json数据
        Gson gson = new Gson();
        String s = gson.toJson(all);
        return s;
    }


}
